package vn.com.vega.music.view.custom;

import vn.com.vega.chacha.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

public class HeaderListSong extends LinearLayout implements OnClickListener {
	private View mPlayAllSong;
	private View mSelectSongPlay;
	private HeaderListSongInterface listener;

	public HeaderListSong(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
		init(context);
	}

	public HeaderListSong(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		init(context);
	}

	public HeaderListSong(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		init(context);
	}

	public void setHeaderListSongInterface(HeaderListSongInterface listener) {
		this.listener = listener;
	}

	private void init(Context ctx) {
		LayoutInflater inflater = (LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.header_list_song, this);
		mPlayAllSong = findViewById(R.id.layout_play_all_song);
		mSelectSongPlay = findViewById(R.id.layout_select_song_play);
		mPlayAllSong.setOnClickListener(this);
		mSelectSongPlay.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (this.listener == null) {
			// Do nothing
			return;
		}
		switch (v.getId()) {
		case R.id.layout_play_all_song:
			listener.playAllSong();
			break;
		case R.id.layout_select_song_play:
			listener.selectSongPlay();
			break;

		default:
			break;
		}
	}

	public interface HeaderListSongInterface {
		public void playAllSong();

		public void selectSongPlay();
	}

}
